#include <iostream>
#include <math.h>
using namespace std;

class diem
{
	int x, y;
public:
	diem();
	diem(int x,int y);
	int getx();
	int gety();
	void setxy(int _x, int _y);
	void inDiem();
};

diem::diem()
{
	x=0;
	y=0;
}

diem::diem(int _x, int _y)
{
	x=_x;
	y=_y;
}

int diem::getx()
{
	return x;
}

int diem::gety()
{
	return y;
}

void diem::setxy(int _x, int _y)
{
	x=_x;
	y=_y;
}

void diem::inDiem()
{
	cout<<"diem co toa do la: ("<<x<<","<<y<<")"<<endl;
}

class HCN
{
	diem diemTT;
	diem diemPD;
public:
	HCN();
	HCN(int x1,int y1,int x2,int y2)
	{
		diem d1,d2;
		d1.setxy(x1,y1);
		d2.setxy(x2,y2);
		setTTPD(d1,d2);
	}
	int setTTPD(diem d1, diem d2);
	bool ktra(diem d1);
};

HCN::HCN()
{
	diemTT.setxy(0,0);
	diemPD.setxy(0,0);
}

int HCN::setTTPD(diem d1, diem d2)
{
	
	if(d1.getx()==d2.getx()||d1.gety()==d2.gety())
	{
		cout<<"day la doan thang! "<<endl<<"moi nhap lai: "<<endl;
		return -1;
	}
	if(d1.getx()>d2.getx()||d1.gety()<d2.gety())
	{
		cout<<"nhap khong dung vi tri. Moi nhap lai! "<<endl;
		return -1;
	}
	else
	{
		diemTT.setxy(d1.getx(),d1.gety());
		diemPD.setxy(d2.getx(),d2.gety());
		return 1;
	}
}
//   a<c       b>d
bool HCN::ktra(diem d1)
{
	int a,b,c,d,e,f;

	a=diemTT.getx();
	b=diemTT.gety();

	c=diemPD.getx();
	d=diemPD.gety();

	e=d1.getx();
	f=d1.gety();

	cout<<endl;
	cout<<"diem TT: ("<<a<<","<<b<<")"<<endl;
	cout<<"diem PD: ("<<c<<","<<d<<")"<<endl;
	cout<<"diem D: ("<<e<<","<<f<<")"<<endl;


	if(e>=a && e<=c && f<=b && f>=d)
	{
		return true;
	}
	else
		return false;

}

class vecto:public diem
{
	diem dau,cuoi;
}

int main()
{
	int a,b,c,d,e,f;
	/*HCN h[5];
	diem d1, d2;
	for(a=1;a<=2;a++)
	{
		cout<<"nhap HCN thu "<<a<<endl;
		cout<<"nhap toa do diem TT: "<<endl;
		cout<<"x: ";
		cin>>c;
		cout<<"y: ";
		cin>>d;
		d1.setxy(c,d);
		cout<<"nhap toa do diem PD: "<<endl;
		cout<<"x: ";
		cin>>e;
		cout<<"y: ";
		cin>>f;
		d2.setxy(e,f);
		if(h[a].setTTPD(d1,d2)!=1)
		a--;
	}
	*/

	HCN h(10,20,30,10);
	diem D[5];
	for(a=1;a<=3;a++)
	{
		cout<<"nhap diem thu "<<a<<endl;
		cout<<"x: ";
		cin>>c;
		cout<<"y: ";
		cin>>d;
		D[a].setxy(c,d);
	}
	for(a=1;a<=3;a++)
	{
		if(h.ktra(D[a])==true)
		{
			D[a].inDiem();
			cout<<"diem "<<a<<" nam trong HCN "<<endl<<endl;
		}
		if (h.ktra(D[a])==false)
		{
			D[a].inDiem();
			cout<<"diem "<<a<<" nam ngoai HCN "<<endl<<endl;
		}
	}
	system("pause");
	return 0;	
}
